#include "nce_proxy.h"

namespace nce
{

Proxy::Proxy(string servName, string hostName, int port)
{
    _servName = servName;
    _client = new ClientSocket(hostName, port);
}

Proxy::~Proxy()
{
    delete _client;
}

int Proxy::invoke(InputBuffer &ib, OutputBuffer &ob)
{	
	string servName;
	
	_client->send(ob);	// need check return value
    cout << "proxy send success" << endl;
	_client->recv(ib);	// need check return value
	cout << "proxy recv success" << endl;

	ib.read(servName);
	if (servName != _servName)
    {
        cout << "proxy check servName error" << endl;
        return -1;
    }

    cout << "proxy check servName success" << endl;
	return 0;
}

}
